package com.MTteam.fragment;

import java.util.List;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.MTteam.domain.HDK_Intro_Info;
import com.MTteam.hdk.R;
import com.MTteam.service.HDK_Intro_Info_ParserService;

public class HDK_Intro_Info_Fragment extends Fragment {
	private ListView lv_info;
	private HDK_Intro_Info_ParserService parserintro;
	private List<HDK_Intro_Info> hDK_Intro_Infos;
	private LayoutInflater myinflater;

	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_hdk_intro_info, null);
		lv_info = (ListView) view.findViewById(R.id.lv_info);
		parserintro = new HDK_Intro_Info_ParserService(getActivity());
		myinflater = LayoutInflater.from(getActivity());
		try {
			hDK_Intro_Infos = parserintro.getInfo();
		} catch (Exception e) {
			e.printStackTrace();
		}
		lv_info.setDivider(null);
		lv_info.setAdapter(new MyAdapter());
		return view;
	}

	class MyAdapter extends BaseAdapter {
		public int getCount() {
			return hDK_Intro_Infos.size();
		}

		public Object getItem(int position) {
			return hDK_Intro_Infos.get(position);
		}

		public long getItemId(int position) {
			return position;
		}

		public View getView(int position, View convertView, ViewGroup parent) {
			View view = myinflater.inflate(
					R.layout.fragment_hdk_intro_info_item, null);
			TextView tv_info = (TextView) view.findViewById(R.id.tv_info);
			tv_info.setText("		" + hDK_Intro_Infos.get(position).getInfo());
			return view;
		}
	}
}
